import { Role } from '@/types/userinfo';
import { GET, POST } from '../index';
const requestURL =  process.env.APP_NOAH_GRAPH_URL
interface Props {
  role: Role;
}

interface UserRole {
  user_id: number;
  role_id: number;
}
interface UserPermission {
  user_id: number;
}

/**
 * 查询管理员列表
 */
export const queryAdminList = (_data: Props) => {
  return [];
};

/**
 * 创建用户
 */
export const addServeUser = (data: any) => {
  return POST<any, []>('/api/v2/serve/user/add', data);
};

/**
 * 编辑用户
 */
export const updateUser = (data: any) => {
  return POST<any, []>('/api/v2/serve/user/update', data);
};

/**
 * 删除用户
 */
export const deleteUser = (data: any) => {
  return POST<any, null>('/api/v2/serve/user/delete ', data);
};

/**
 * 重置密码
 */
export const restorePwd = (data: any) => {
  return POST<any, null>('/api/v2/serve/user/restorePwd ', data);
};

/**
 * 用户列表
 */
export const getServeUserList = (data: any) => {
  return POST<any, null>('/api/v2/serve/user/query_page_like', data);
};

/**
 * 角色列表
 */
export const getRoleList = (data: any) => {
  return POST<any, null>('/api/v2/serve/role/list', data);
};

/**
 * 当前用户角色列表
 */
export const getUserRoleList = (data: UserPermission) => {
  return POST<any, null>(`/api/v2/serve/user/user_role_info?user_id=${data.user_id}`);
};

/**
 * 分配用户角色
 */
export const setUserRole = (data: UserRole) => {
  return POST<any, null>(`/api/v2/serve/user/assign_role?user_id=${data.user_id}&role_id=${data.role_id}`);
};

/**
 * 当前用户权限列表
 */
export const getUserPermissionList = (data: UserPermission) => {
  return POST<any, null>(`/api/v2/serve/user/query_user_permission?user_id=${data.user_id}`);
};

/**
 * 获取所有权限列表
 */
export const getAllUserPermissionList = (data: any) => {
  return POST<any, null>(`/api/v2/serve/permissions/list`, data);
};

/**
 * 分配用户权限
 */
export const setUserPermission = (data: any) => {
  return POST<any, null>('/api/v2/serve/user/assign_permissions', data);
};
//获取指标模型
export const metricmodelInfoGet = (id: string) => {
  return GET<any, null>(requestURL + '/ds/metric-model-info/get?id=' + id)
}
//获取指标模型日志列表
export const indicatorModelLog = (data: Object) => {
  return POST<any, null>(requestURL + '/ds/metric-model-info/logList', data)
}
//点击表查询详情
export const tableDetailsInfo = (id: string) => {
  return GET<any, null>(requestURL + '/ai/metric-query/tableDetails?id=' + id)
}
//数据源sql执行(无登陆无租户)
export const sqlExecute = (data: Object) => {
  return POST<any, null>(requestURL + '/settings/connect/executeSql', data)
}
export const update_gen_comment = (data: Object) => {
  return POST<any, null>('/api/v2/serve/logo/db-table-set/update_gen_comment', data)
}